Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mypy test #7478

Merged
merged 5 commits into from
Mar 13, 2022
Merged

Fix mypy test #7478

merged 5 commits into from
Mar 13, 2022

Conversation

JelleZijlstra
Copy link
Member

Because we didn't set mypy's clean_exit parameter, it was
exiting immediately after checking the stdlib.

This exposed two issues:

  • types-requests has a version-limited dependency on types-urllib3, which we crashed on
  • mypy crashes checking the SQLAlchemy stubs. Not sure if that's a known issue.

Because we didn't set mypy's clean_exit parameter, it was
exiting immediately after checking the stdlib.

This exposed two issues:
- types-requests has a version-limited dependency on types-urllib3, which we crashed on
- mypy crashes checking the SQLAlchemy stubs. Not sure if that's a known issue.
@JelleZijlstra
Copy link
Member Author

JelleZijlstra commented Mar 13, 2022

SQLAlchemy stack trace:

Traceback (most recent call last):
  File "/Users/jelle/py/typeshed/tests/mypy_test.py", line 346, in <module>
    main()
  File "/Users/jelle/py/typeshed/tests/mypy_test.py", line 330, in main
    this_code, checked = test_third_party_distribution(distribution, major, minor, args)
  File "/Users/jelle/py/typeshed/tests/mypy_test.py", line 277, in test_third_party_distribution
    code = run_mypy(args, configurations, major, minor, files)
  File "/Users/jelle/py/typeshed/tests/mypy_test.py", line 194, in run_mypy
    mypy_main("", sys.stdout, sys.stderr, clean_exit=True)
  File "/Users/jelle/py/mypy/mypy/main.py", line 96, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
  File "/Users/jelle/py/mypy/mypy/main.py", line 173, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "/Users/jelle/py/mypy/mypy/build.py", line 180, in build
    result = _build(
  File "/Users/jelle/py/mypy/mypy/build.py", line 256, in _build
    graph = dispatch(sources, manager, stdout)
  File "/Users/jelle/py/mypy/mypy/build.py", line 2727, in dispatch
    process_graph(graph, manager)
  File "/Users/jelle/py/mypy/mypy/build.py", line 3071, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/jelle/py/mypy/mypy/build.py", line 3189, in process_stale_scc
    graph[id].write_cache()
  File "/Users/jelle/py/mypy/mypy/build.py", line 2311, in write_cache
    new_interface_hash, self.meta = write_cache(
  File "/Users/jelle/py/mypy/mypy/build.py", line 1488, in write_cache
    data = tree.serialize()
  File "/Users/jelle/py/mypy/mypy/nodes.py", line 344, in serialize
    'names': self.names.serialize(self._fullname),
  File "/Users/jelle/py/mypy/mypy/nodes.py", line 3364, in serialize
    data[key] = value.serialize(fullname, key)
  File "/Users/jelle/py/mypy/mypy/nodes.py", line 3301, in serialize
    data['node'] = self.node.serialize()
  File "/Users/jelle/py/mypy/mypy/nodes.py", line 953, in serialize
    "type": None if self.type is None else self.type.serialize(),
  File "/Users/jelle/py/mypy/mypy/types.py", line 1482, in serialize
    'variables': [v.serialize() for v in self.variables],
  File "/Users/jelle/py/mypy/mypy/types.py", line 1482, in <listcomp>
    'variables': [v.serialize() for v in self.variables],
  File "/Users/jelle/py/mypy/mypy/types.py", line 611, in serialize
    'upper_bound': self.upper_bound.serialize(),
  File "/Users/jelle/py/mypy/mypy/types.py", line 1079, in serialize
    type_ref = self.type.fullname
  File "/Users/jelle/py/mypy/mypy/nodes.py", line 2914, in __getattribute__
    raise AssertionError(object.__getattribute__(self, 'msg'))
AssertionError: De-serialization failure: TypeInfo not fixed

JelleZijlstra added a commit that referenced this pull request Mar 13, 2022
JelleZijlstra added a commit that referenced this pull request Mar 13, 2022
They use http.client, which is Python 3-only. Another catch from #7478.
hauntsaninja pushed a commit that referenced this pull request Mar 13, 2022
AlexWaygood pushed a commit that referenced this pull request Mar 13, 2022
They use http.client, which is Python 3-only. Another catch from #7478.
AlexWaygood added a commit that referenced this pull request Mar 13, 2022
It has to be imported from `typing` in <3.7. Refs #7478.
@AlexWaygood
Copy link
Member

#7482 for the parsimonious error.

hauntsaninja pushed a commit that referenced this pull request Mar 13, 2022
It has to be imported from `typing` in <3.7.
Refs #7478.
@AlexWaygood
Copy link
Member

The urllib errors come from checking requests on Python 2; requests is marked as being Python 2-compatible, but imports urllib3, which isn't Python 2-compatible. The easiest fix is probably just to mark requests as no longer being Python 2-compatible.

AlexWaygood added a commit that referenced this pull request Mar 13, 2022
See #7478 (comment): `types-requests` imports `types-urllib3`, and `types-urllib3` is incompatible with Python 2.
@AlexWaygood
Copy link
Member

The urllib errors come from checking requests on Python 2; requests is marked as being Python 2-compatible, but imports urllib3, which isn't Python 2-compatible. The easiest fix is probably just to mark requests as no longer being Python 2-compatible.

#7483 to do that.

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, once the problems are resolved.

@AlexWaygood AlexWaygood merged commit fa33222 into python:master Mar 13, 2022
AlexWaygood added a commit that referenced this pull request Mar 13, 2022
* Run mypy on the 3.11 stdlib in CI, as a regression test for python/mypy#12220
* Correct the docstring at the top of the file following the changes made in #7478
* Stop the test from crashing when run locally if there's an extra file/folder in the stubs directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants